package com.greatwqs.wmall.common.provider.config;

import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author wang-qingsong
 * @since 2025/03/12
 */
@Configuration
public class ModelMapperConfig {

    @Bean
    public ModelMapper modelMapper() {
        ModelMapper modelMapper = new ModelMapper();
        // https://github.com/modelmapper/modelmapper/issues/239
        // 源属性和目标属性一对一匹配
        modelMapper.getConfiguration().setAmbiguityIgnored(true);
        // 属性类型精确匹配
        modelMapper.getConfiguration().setFullTypeMatchingRequired(true);
        // 属性名字精确匹配
        modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
        return modelMapper;
    }
}
